import router from "./index";
import NProgress from 'nprogress';
import 'nprogress/nprogress.css'; // 引入样式
// import { useUserStore } from '@/stores/user'; // 导入 useUserStore
import useLoading from '@/utils/loading';

NProgress.inc(100)
NProgress.configure({easing:'ease',speed:200,showSpinner:false})

const {openLoading,closeLoading} = useLoading();
let loading:any;
// console.log("-------",router)
router.beforeEach((to, from, next) => {
	// ...
	NProgress.start();
	loading = openLoading();
	// const hasToken = localStorage.getItem('accessToken');
	// if(hasToken){
		// const userStore = useUserStore()
	// }
	next();
})

router.afterEach(()=>{
	closeLoading(loading);
	NProgress.done();
})
